package com.jadcon.harveycedars.model.dormitory;

import java.util.ArrayList;
import java.util.List;

public class Room {
	
	private List<Person> personList = new ArrayList<Person>();
	private String number;
	private int sizeLimit;
	private int floorLevel;

	// default constructor
	public Room() { }
	
	// Pass in a size limit when you create the room
	public Room(String number, int sizeLimit) {
		this.number = number;
		this.sizeLimit = sizeLimit;
	}
	
	// How do I get the room number to come up automatically rather than
	// have to manually type it out?==
	public String toString () {
		StringBuilder sb = new StringBuilder();
		sb.append("Room number ");
		sb.append(number);
		return sb.toString();
	}
	
	
	public void addPerson(Person person) {
		// check to see if the room is full
		if (personList.size() == sizeLimit) {
			// the room is already full, so throw an exception
			throw new RuntimeException("Dorm is already full, cannot add Person");
		}
		// add the Person to the internal list
		personList.add(person);
	}
	
	public void removePerson(Person person) {
		personList.remove(person);
	}
	
	public int getPercentAvailable() {
		if (personList.size() > 0) {
			return (sizeLimit / personList.size()) * 10;
		}
		return 0;
	}
	
	
	public int getBedsAvailable() {
		return (sizeLimit-personList.size());
	}
	
	
	
		
	public int getTotalGuests() {
		return (personList.size());
	}

	public List<Person> getPersonList() {
		//if personList.isEmpty() = return "empty"; - how do I return this?
		// how do I split \ slice the list to return each name on a separate line? array.slice?
		return personList;
	}

	public String getNumber() {
		return number;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	public int getTotalBeds() {
		return sizeLimit;
	}

	public int getFloorLevel() {
		return floorLevel;
	}

	public int getSizeLimit() {
		return sizeLimit;
	}

	public void setSizeLimit(int sizeLimit) {
		this.sizeLimit = sizeLimit;
	}

}
